#!/usr/bin/env python

import sys, json, fileinput, Image
from collections import defaultdict

def main (argv0, argv):
    colors = defaultdict(lambda: (255, 255, 255), {
        1: (0, 0, 0),       # black
        2: (255, 0, 0),     # red
        3: (0, 0, 255),     # blue
        4: (0, 255, 0),     # green
        5: (255, 255, 0),   # yellow
        6: (0, 255, 255),   # cyan
        7: (255, 0, 255),   # magenta
    })
    level = json.loads("".join(fileinput.input()))
    w, h = map(int, (level["width"], level["height"]))
    block_data = level["block_data"]
    img = Image.new("RGB", (w, h))
    i = 0
    for y in range(h):
        for x in range(w):
            datum = block_data[i]
            color = colors[datum]
            i += 1
            img.putpixel((x, y), color)
    for p in level["enemies"]:
        x, y = p["x"], p["y"]
        int(x)
    img.save(sys.stdout, "PNG")

if __name__ == "__main__":
    try:
        exit_code = main(sys.argv[0], sys.argv[1:])
    except KeyboardInterrupt:
        exit_code = 1
    sys.exit(exit_code)
